package com.tarena.lbs.basic.dao.repository.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tarena.lbs.basic.dao.mapper.AreaMapper;
import com.tarena.lbs.basic.dao.repository.AreaRepository;
import com.tarena.lbs.basic.pojo.po.AreaPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Collections;
import java.util.List;
@Repository
public class AreaRepositoryImpl implements AreaRepository {
    @Autowired
    private AreaMapper areaMapper;
    @Override
    public List<AreaPO> getChildren(Integer parentId) {
        QueryWrapper<AreaPO> queryWrapper=new QueryWrapper();
        queryWrapper.eq("parent_id",parentId);
        return areaMapper.selectList(queryWrapper);
    }

    @Override
    public List<AreaPO> getAll() {
        return areaMapper.selectList(null);
    }

    @Override
    public List<AreaPO> queryArea(List<Long> idList) {
        QueryWrapper<AreaPO> queryWrapper=new QueryWrapper();
        queryWrapper.in("id",idList);
        List<AreaPO> list = areaMapper.selectList(queryWrapper);
        return list.isEmpty() ? Collections.emptyList() : list;
    }
}
